<script>
	import * as index from '@/api/index/index.js'
	import conVersion from './config/index.js'
	export default {
		onLaunch: function() {
		},
		onShow: function(){
			//#ifdef APP-PLUS
			var args = plus.runtime.arguments;
			if(plus.runtime.arguments){
				plus.runtime.arguments = ""
			}
			if (args == 'pinlehui://paySuccess') {
				uni.navigateTo({
					url:'/pages/order/payScuess?status=0'
				})
			}
			//#endif
			var that = this
			setTimeout(function(){
				that.getVersion()
			},1000)
		},
		data() {
			return {
				type: null,
			}
		},
		methods:{
			getVersion() {
				const res = uni.getSystemInfoSync();
				if (res.platform == 'android') {
					this.type = 0
				} else if (res.platform == 'ios') {
					this.type = 1
				}
				index.version().then(res => {
					var url = this.type == 0 ? res.data.obj.androidAddress : res.data.obj.iosAddress;
					var currentVersion = this.type == 0 ? res.data.obj.androidVersion : res.data.obj.iosVersion
					var version = this.type == 0 ? conVersion.ANDROIDVersion : conVersion.IOSVersion
					if (version != currentVersion) {
						uni.showModal({ //提醒用户更新
							title: '更新提示',
							confirmText:'立即更新',
							content: this.type == 0 ? res.data.obj.androidInfo:res.data.obj.iosInfo,
							showCancel: false,
							success: (res) => {
								if (res.confirm) {
									console.log(url)
									plus.runtime.openURL(url);
								} else {
									uni.showToast({
										title: '取消更新',
										icon: "none",
										duration: 2000
									})
								}
							}
						})
			
					}
				})
			},
		}
	}
</script>

<style lang="scss">
	@import "uview-ui/index.scss";
	@import "/static/iconfont/font.scss";
	@import url("components/ly-tree/ly-tree.css");
	/*每个页面公共css */
	.status_bar {
		height: var(--status-bar-height);
		width: 100%;
	}
	page{
		background-color: #f6f6f6 !important;
	}
	.uni-searchbar{
		align-items: center;
	}
	input{
		padding: 0!important;
	}
	.u-more::before{
		width: 0!important;
	}
	.uni-numbox__value{
		background: #f8f8f8!important;
	}
	.uni-searchbar__box{
		border: 0!important;
		height: 60rpx!important;
		}
		.uni-searchbar__text-placeholder,.uni-searchbar__cancel,.uni-searchbar__box-search-input{
			font-size: 25rpx!important;
		}
		.uni-searchbar__box-icon-clear .uni-icons{
			font-size: 35rpx!important;
		}
		uni-radio .uni-radio-input {
			width: 50rpx!important;
			height: 50rpx!important;
			font-size: 25rpx;
		}
		.bankBox uni-radio .uni-radio-input {
			width: 30rpx!important;
			height: 30rpx!important;
			font-size: 25rpx;
		}
		.resles .uni-nav-bar-text{
			margin-right: -80rpx;
		}
		.resles .uni-navbar__header-btns-right{
			width: 0!important;
		}
		.uni-navbar--border{
		    border-bottom: none!important;
		}
		
		button::after {
			border: none !important;
		}
		
		/*边框*/
		.b-b:after,
		.b-t:after {
			position: absolute;
			z-index: 3;
			left: 0;
			right: 0;
			height: 0;
			content: '';
			transform: scaleY(.5);
			border-bottom: 1px solid #f5f5f5;
		}
		
		.b-b:after {
			bottom: 0;
		}
		
		.b-t:after {
			top: 0;
		}
		
		/* button样式改写 */
		uni-button,
		button {
			&.no-border:before,
			&.no-border:after {
				border: 0;
			}
		}
</style>
